package com.bit.dreamer;


import android.app.ActionBar;
import android.app.TabActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.TabHost;
import android.widget.Toast;

@SuppressWarnings("deprecation")
public class DreamlistActivity extends TabActivity  {

	SharedPreferences sf;
	TabHost tabHost;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		tabHost = getTabHost();

		ActionBar actionbar = getActionBar();
		sf = getSharedPreferences("name", MODE_PRIVATE);
		String nName = sf.getString("name", "");
		actionbar.setTitle(nName + "님 안녕하세요");
		actionbar.setDisplayShowHomeEnabled(false);


		Intent int1 = new Intent(this, Dreamlist_doActivity.class);
		int1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 
		  //FLAG_ACTIVITY 속성 네이버에서 검색하면 나옴 
 
		tabHost.addTab(tabHost.newTabSpec("tab1")
				.setIndicator("하고")
				.setContent(int1));

		Intent int2 = new Intent(this, Dreamlist_haveActivity.class);
		int1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		tabHost.addTab(tabHost.newTabSpec("tab2")
				.setIndicator("갖고")
				.setContent(int2));

		Intent int3 = new Intent(this, Dreamlist_becomeActivity.class);
		int1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		tabHost.addTab(tabHost.newTabSpec("tab3")
				.setIndicator("되고")
				.setContent(int3));

		switch (getIntent().getIntExtra("bt_select", 0)) {
		case 1:
			tabHost.setCurrentTab(0);
			break;

		case 2:
			tabHost.setCurrentTab(1);
			break;

		case 3:
			tabHost.setCurrentTab(2);
			break;

		}

	}	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		// Inflate the menu; this adds items to the action bar if it is present.
		//		getMenuInflater().inflate(R.menu.lotto_main, menu);
		//		return true;

		super.onCreateOptionsMenu(menu);

		MenuItem item = menu.add(0, 1, 0, "로그인");
		item.setIcon(R.drawable.ic_launcher);
		item.setAlphabeticShortcut('a'); // 키보드 a를 누르면 실행되게끔

		menu.add(0, 2, 0, "꿈등록");
		menu.add(0, 3, 0, "꿈목록");
		menu.add(0, 4, 0, "꿈지도");
		menu.add(0, 5, 0, "메뉴들");


		//기타옵션 없어서 일단주석 SubMenu etc = menu.addSubMenu("성격검사");
		//					etc.add(0, 4, 0, "참고1");
		//	                etc.add(0, 5, 0, "참고2");

		return true;
	}


	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch ( item.getItemId()){
		case 1:
			Intent intent1= new Intent(getApplicationContext(), MainActivity.class);
			startActivity(intent1);

			Toast.makeText(this, "로그인 화면 가기", Toast.LENGTH_SHORT).show();
			return true;

		case 2 :
			Intent intent2= new Intent(getApplicationContext(), DreaminsertActivity.class);
			startActivity(intent2);
			Toast.makeText(this, "나의 꿈 등록 하기", Toast.LENGTH_SHORT).show();
			return true;

		case 3 :
			Intent intent3= new Intent(getApplicationContext(), MainMenuActivity.class);
			startActivity(intent3);

			Toast.makeText(this, "나의 꿈 목록 보기", Toast.LENGTH_SHORT).show();
			return true;

		case 4 :
			Intent intent4= new Intent(getApplicationContext(), DreamMap.class);
			startActivity(intent4);

			Toast.makeText(this, "나의 꿈 지도 보기", Toast.LENGTH_SHORT).show();
			return true;

		case 5 :
			Intent intent5= new Intent(getApplicationContext(), com.bit.dreamer.SubMenu.class);
			startActivity(intent5);

			Toast.makeText(this, "다양한 메뉴들 보기", Toast.LENGTH_SHORT).show();
			return true;

		}

		return false;
	}

}
